from selenium.webdriver.common.by import By
from base.base_page import BasePage, BaseOperate
from utils import select_box, UtilsDriver


# 页面层
class NoticeCheckListPage(BasePage):
	def __init__(self):
		super().__init__()
		self.sn_server = By.CSS_SELECTOR, "[class='bottom'] input"
		self.sn_not_approved = By.CSS_SELECTOR, "[role='tablist'] [id='tab-notAudit']"
		self.n_open_record_button = By.CSS_SELECTOR, "[class='el-table__body-wrapper is-scrolling-none'] i[class='el-icon el-icon-arrow-right']"
		self.n_sort_no = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[2]/div"
		self.n_notice_id = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[3]/div"
		self.n_server = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[4]/div/span"
		self.n_notice_type = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[5]/div"
		self.n_notice_show = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[6]/div"
		self.n_start_time = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[7]/div"
		self.n_end_time = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[8]/div"
		self.n_theme = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr/td[9]/div/span"
		self.n_examine_button = By.XPATH, "//*[@class='el-button el-button--primary el-button--mini']"
		self.n_play_time = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody/tr[2]/td/form/div[3]/div[3]/div/div/span"
		self.n_notice_content = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody/tr[2]/td/form/div[6]/div/div/div/span"
		self.approved_button = By.XPATH, "//*[@class='el-button el-button--default el-button--small el-button--primary ']"
		self.not_approved_button = By.XPATH, "//*[@class='el-button el-button--default el-button--small']"
		self.s_approved = By.CSS_SELECTOR, "[role='tablist'] [id='tab-audit']"
		self.s_status = By.XPATH, "//*[@class='searchbox']/div[1]//input"
		self.s_server = By.XPATH, "//*[@class='searchbox']/div[1]//input"
		self.notice_status = By.XPATH, "//*[@class='el-table__body-wrapper is-scrolling-none']//tbody[1]/tr[1]/td[10]/div/a/span/span"

	def find_sn_server(self):
		return self.get_element(self.sn_server)

	def find_sn_not_approved(self):
		return self.get_element(self.sn_not_approved)

	def find_n_open_record_button(self):
		return self.get_element(self.n_open_record_button)

	def find_n_sort_no(self):
		return self.get_element(self.n_sort_no)

	def find_n_notice_id(self):
		return self.get_element(self.n_notice_id)

	def find_n_server(self):
		return self.get_element(self.n_server)

	def find_n_notice_type(self):
		return self.get_element(self.n_notice_type)

	def find_n_notice_show(self):
		return self.get_element(self.n_notice_show)

	def find_n_start_time(self):
		return self.get_element(self.n_start_time)

	def find_n_end_time(self):
		return self.get_element(self.n_end_time)

	def find_n_theme(self):
		return self.get_element(self.n_theme)

	def find_n_examine_button(self):
		return self.get_element(self.n_examine_button)

	def find_n_play_time(self):
		return self.get_element(self.n_play_time)

	def find_n_notice_content(self):
		return self.get_element(self.n_notice_content)

	def find_approved_button(self):
		return self.get_element(self.approved_button)

	def find_not_approved_button(self):
		return self.get_element(self.not_approved_button)

	def find_s_approved(self):
		return self.get_element(self.s_approved)

	def find_s_status(self):
		return self.get_element(self.s_status)

	def find_s_server(self):
		return self.get_element(self.s_server)

	def find_notice_status(self):
		return self.get_element(self.notice_status)


# 操作层
class NoticeCheckListOperate(BaseOperate):
	def __init__(self):
		self.page_obj = NoticeCheckListPage()

	def input_sn_server(self, sn_server):
		select_box(UtilsDriver.get_web_driver(), self.page_obj.find_sn_server(), sn_server)

	def click_sn_not_approved(self):
		self.page_obj.find_sn_not_approved().click()

	def click_n_open_record_button(self):
		self.page_obj.find_n_open_record_button().click()

	def get_n_sort_no_text(self):
		return self.page_obj.find_n_sort_no().text

	def get_n_notice_id_text(self):
		return self.page_obj.find_n_notice_id().text

	def get_n_server_text(self):
		return self.page_obj.find_n_server().text

	def get_n_notice_type_text(self):
		return self.page_obj.find_n_notice_type().text

	def get_n_notice_show_text(self):
		return self.page_obj.find_n_notice_show().text

	def get_n_start_time_text(self):
		return self.page_obj.find_n_start_time().text

	def get_n_end_time_text(self):
		return self.page_obj.find_n_end_time().text

	def get_n_theme_text(self):
		return self.page_obj.find_n_theme().text

	def click_n_examine_button(self):
		self.page_obj.find_n_examine_button().click()

	def get_n_play_time_text(self):
		return self.page_obj.find_n_play_time().text

	def get_n_notice_content_text(self):
		return self.page_obj.find_n_notice_content().text

	def click_approved_button(self):
		self.page_obj.find_approved_button().click()

	def click_not_approved_button(self):
		self.page_obj.find_not_approved_button().click()

	def click_s_approved(self):
		self.page_obj.find_s_approved().click()

	def input_s_status(self, s_status):
		select_box(UtilsDriver.get_web_driver(), self.page_obj.find_s_status(), s_status)

	def input_s_server(self, s_server):
		select_box(UtilsDriver.get_web_driver(), self.page_obj.find_s_server(), s_server)

	def get_notice_status_text(self):
		return self.page_obj.find_notice_status().text


# 业务层
class NoticeCheckListBusiness:
	def __init__(self):
		self.operate_obj = NoticeCheckListOperate()